package com.mychart.data;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

import java.util.concurrent.ConcurrentHashMap;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_SINGLETON;

@Component()
@Scope(scopeName = SCOPE_SINGLETON)
public class LoginUserSussionRepository extends ConcurrentHashMap<String, WebSocketSession> {

    public void addLoginUser(String name,WebSocketSession userSession) {
        put(name,userSession);
    }

    public void userLogout(String name) {
        remove(name);
    }
}
